import { Module, Global } from '@nestjs/common';
import { DbService } from './db.service';
import { TypegooseModule } from 'nestjs-typegoose';
import { User } from './model/user.model';
import { Tab } from './model/tab.model';
import { TabCollection } from './model/tabCollection.model';
import { TabDetail } from './model/tabDetail.model';
import { Workspace } from './model/workspace.model';

const models = TypegooseModule.forFeature([
  User,
  Tab,
  TabCollection,
  TabDetail,
  Workspace,
]);

@Global()
@Module({
  imports: [
    TypegooseModule.forRoot(
      'mongodb://admin:123456@localhost:27017/database?authSource=admin',
    ),
    models,
  ],
  providers: [DbService],
  exports: [DbService, models],
})
export class DbModule {}
